package cn.zktr.Personnel.controllers.zhouxiong;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import cn.zktr.Personnel.model.pojos.PerCwaSst;
import cn.zktr.Personnel.model.service.zhouxiong.JiChuService;
import cn.zktr.Personnel.model.service.zhouxiong.KaoQinKaService;
import cn.zktr.Personnel.model.service.zhouxiong.NoimpService;

@Controller
public class TiaoBanController {

	@Autowired
	private KaoQinKaService kqk;
	@Autowired
	private JiChuService jichu;
	@Autowired
	private NoimpService noimp;
	

	@RequestMapping("zx/tiao-ban")
	public void tiaoban(Model model) {
//		kaoqin( model);
	}
	
	
	@RequestMapping("BanZuRenYuan")
	@ResponseBody
	public Map<String,Object> paiban(int page,int rows) {
		Map<String,Object> map = new HashMap<>();
		map.put("total",kqk.selePaiBan().size());
		Page<Object> p=PageHelper.startPage(page,rows);
		JSONArray findAll=kqk.selePaiBan();
		//页内容
		map.put("rows",findAll);
//		kaoqin( model);
		return map;
	}
	
	@RequestMapping("TiaoBan")
	@ResponseBody
	public Map<String,Object> tiaoban(int page,int rows) {
		Map<String,Object> map = new HashMap<>();
		map.put("total",noimp.seleTiaoBan().size());
		Page<Object> p=PageHelper.startPage(page,rows);
		JSONArray findAll=noimp.seleTiaoBan();
		//页内容
		map.put("rows",findAll);
		return map;
	}
	
	@PostMapping("updateTB")
	@ResponseBody
	public String addTB(Integer empid,Integer cwaid,Integer cwasid,Integer rsnid,Integer sstrem) {
		noimp.updateCwa(empid, cwaid, cwasid);
		noimp.updateTB(empid, cwaid, cwasid, rsnid, sstrem);
		return "";
	}
	
//	public void kaoqin(Model model) {
//		model.addAttribute("KaoQinKa", kqk.seleKaoQinKa());					//考勤卡
//		model.addAttribute("PaiBan", kqk.selePaiBan());                       //排班
//		model.addAttribute("YuanYin", jichu.seleYuanYin());                   //原因
//		model.addAttribute("BanCi", jichu.selectBanCi());                     //班次
//		model.addAttribute("BanZu", jichu.selectBanZu());                     //班组
//		model.addAttribute("QinJiaZhongLei", jichu.seleQinJiaZhongLei());     //请假种类
//	}
}
